import React from 'react';
import { Button, Space } from 'antd';
import CommonModal from "@/components/CommonModal";
import IconFont from '@/components/IconFont';
import { handleExportExcel2 } from '@/utils/utils.jsx';

const BatchPushGoodsModal =  ({ visible, handleCancel, pushData }) => {
  const { printedFailUniqueCodes, printedSuccessUniqueCodes } = pushData || {};

  const handleOk = () => {
    START_LOADING();
    handleExportExcel2(
      '/new-wms/fmcgpurchases/exportPushFailedRecord',
      { codes: printedFailUniqueCodes }, 
       '待拿货推送失败.xlsx', 
       () => {
        handleCancel();
        END_LOADING();
       },
    )
  }

	return (
		<CommonModal 
      visible={visible} 
      title="操作提示" 
      onCancel={handleCancel}
      minHeight={120}
      footer={[
        <Button key="cancel" onClick={handleCancel}>取消</Button>,
        <Button key="export" type="primary" onClick={handleOk} disabled={!printedFailUniqueCodes?.length}>导出失败内容</Button>
      ]}
    >
      <Space style={{ fontSize: 16 }}>
			  <IconFont type="iconjingshi"/>
        <span className='common-color13'>提示</span>
      </Space>
      <div style={{ marginLeft: 24 }}>
        <span className="common-color10">成功</span> 推送 {printedSuccessUniqueCodes?.length} 个商品，
        <span className="common-color9">失败</span> 推送 {printedFailUniqueCodes?.length} 个商品
        <div style={{ fontSize: 12, color: '#999'}}>仅对“待拿货”商品操作推送供应商</div>
      </div>
		</CommonModal>
	);
};

export default BatchPushGoodsModal;
